*==========================================================================================================================================================
*
*	GRAPHS and TABLES
*
*==========================================================================================================================================================


set more off

qui {



*_________ GET DATA ____________
use "`path'data/working files/prepared.dta", clear 




//Figure A.5
//validity test: Amsterdam on London short sight bill (i.e. spot exchange rate proxy) vs. Gold-silver ratio 
preserve

replace l_ams_lon_ss_hp = l_ams_lon_ss_hp*100
replace l_gs_rate_hp = l_gs_rate_hp*100
la var l_ams_lon_ss_hp "Amsterdam on London, short sight"
la var l_gs_rate_hp "Silver-gold rate"

twoway (scatter l_ams_lon_ss_hp year if year >= 1720 & year <= 1810, connect(l) sort cmissing(n) mlabposition(3) msymbol(none) lcolor(black) msize(vsmall) xlabel(1720 1725(25)1800 1810) ylabel(#3, angle(0) nogrid)) ///
(scatter l_gs_rate_hp year if year >= 1720 & year <= 1810, connect(l) sort cmissing(n) lcolor(gs7) msize(vsmall) msymbol(none) mcolor(gs7) lpattern(longdash)),  ///
xtitle("Year") ytitle("Percent deviation from trend") plotregion(color(white)) graphregion(color(white)) name(er_gs, replace) ///
legend(col(2) region(lcolor(white))) 
graph display er_gs, ysize(1) xsize(2)
graph export "results/FigureA8.pdf", replace

corr l_ams_lon_ss_hp l_gs_rate_hp if year >= 1720 & year <= 1810
reg l_ams_lon_ss_hp l_gs_rate_hp if year >= 1720 & year <= 1810

restore




//Figure A.6
preserve
gen disa = log_R_esp_er_hp if disaster==1

la var log_R_esp_er_hp "Lending rate (ppt trend deviations)"
la var disa "Disaster years"

twoway (scatter disa year if year >=1531, msymbol(th) mcolor(black) msize(normal)) ///
(scatter disa year if year >=1531, msymbol(t) mcolor(white) fcolor(white) lcolor(white) msize(normal)) ///
(line log_R_esp_er_hp year if year >=1531, mlabposition(3) msymbol(none) lcolor(gs10) msize(vsmall) xtitle("Year")  xlabel(1531 1550(50)1750 1810) ytitle(Lending rate (ppt trend deviations)) ylabel(-20(10)20, angle(0) nogrid)) ///
(scatter disa year if year >=1531 [w=percloss_netN], msymbol(th) mcolor(black) msize(tiny)), ///
legend(order(1) pos(8) ring(0) col(1) lab(4 "Maritime disasters") region(lcolor(white))) ///
plotregion(color(white)) graphregion(color(white)) name(rate_event, replace) nodraw
graph display rate_event, ysize(1) xsize(2)
graph export "results/FigureA9.pdf", replace
restore




//Figure A.8
preserve
gen disa = l_esp_rate_hp if disaster==1

la var l_esp_rate_hp "Lending rate (ppt trend deviations)"
la var disa "Disaster years"

twoway (scatter disa year if year >=1531, msymbol(th) mcolor(black) msize(normal)) ///
(scatter disa year if year >=1531, msymbol(t) mcolor(white) fcolor(white) lcolor(white) msize(normal)) ///
(line l_esp_rate_hp year if year >=1531, cmissing(n) mlabposition(3) msymbol(none) lcolor(gs10) msize(vsmall) xtitle("Year")  xlabel(1531 1550(50)1750 1810) ytitle(Lending rate (ppt trend deviations)) ylabel(-60(20)60, angle(0) nogrid)) ///
(scatter disa year if year >=1531 [w=percloss_netN], msymbol(th) mcolor(black) msize(tiny)), ///
legend(order(1) pos(8) ring(0) col(1) lab(4 "Maritime disasters") region(lcolor(white))) ///
plotregion(color(white)) graphregion(color(white)) name(rate2_event, replace) nodraw
graph display rate2_event, ysize(1) xsize(2)
graph export "results/FigureA11.pdf", replace
drop disa
restore





//Table B.1
//Regress silver inflows on Spanish exports
gen xti = exports_esp/20*pesograms*10^6/(in_esp*1000*1000)
n sum xti
n display `"Exports/Precious metal inflows : `r(mean)'"'


reg in_esp_gr exports_esp_gr
eststo m1
mat pval = Ftail(e(df_m), e(df_r), e(F)) 
estadd scalar pval = pval[1,1]: m1

reg in_esp_gr l.exports_esp_gr
eststo m2
mat pval = Ftail(e(df_m), e(df_r), e(F))
estadd scalar pval = pval[1,1]: m2

reg in_esp_gr l2.exports_esp_gr
eststo m3
mat pval = Ftail(e(df_m), e(df_r), e(F))
estadd scalar pval = pval[1,1]: m3

reg in_esp_gr l(0/1).exports_esp_gr
eststo m4
mat pval = Ftail(e(df_m), e(df_r), e(F))
estadd scalar pval = pval[1,1]: m4

la var in_esp_gr "Silver inflows (growth rate)"
la var exports_esp_gr "Spanish export (growth rate)" //(in million Maravedi de vellon)

		esttab m1 m2 m4 using "results/TableB1.tex", replace ///
		cells("b(fmt(2) star)" (se(fmt(2) par))) ///
		starlevels(* 0.10 ** 0.05 *** 0.01) ///
		label ///
		nomtitles ///
		collabels(none) ///
		nonum ///
		nocons ///
		stats(pval r2 N, fmt(2 2 0) labels("F-statistic (p-value)" "R squared" "Observations" )) //



}


*_________________________________________

			
